Skip to content

按类型获取公告 - GetAnnouncementsByType

函数简介

按公告类型获取公告列表。

返回数据格式:

json
{
  "Code": 1,
  "Message": "",
  "TotalCount": 1,
  "Items": [
    {
      "Guid": "a0b1c2d3",
      "Title": "公告标题",
      "Content": "公告正文",
      "AnnouncementType": 1,
      "AnnouncementTypeText": "系统公告",
      "Priority": 1,
      "PriorityText": "普通",
      "IsPopup": true,
      "IsTop": false,
      "SortOrder": 10,
      "PublishTime": "2026-04-20 08:00:00",
      "ExpireTime": "2026-05-20 08:00:00",
      "TargetUrl": "",
      "IsRead": false
    }
  ]
}
字段名类型说明
Code整数结果状态码,通常 1 表示成功,0 或其他值表示失败。
Message字符串提示信息或错误信息,成功时通常为空字符串。
TotalCount整数总数量。
Items数组公告结果列表,每个元素为一个公告对象。

Items 元素字段说明:

字段名类型说明
Guid字符串公告唯一标识。
Title字符串公告标题。
Content字符串公告正文内容。
AnnouncementType整数公告类型编码。
AnnouncementTypeText字符串公告类型文本说明。
Priority整数优先级编码。
PriorityText字符串优先级文本说明。
IsPopup布尔是否弹窗展示。
IsTop布尔是否置顶。
SortOrder整数排序值,值越小越靠前。
PublishTime字符串公告发布时间。
ExpireTime字符串公告过期时间。
TargetUrl字符串公告关联跳转链接。
IsRead布尔当前用户是否已读。

接口名称

GetAnnouncementsByType

DLL调用

long GetAnnouncementsByType(string userCode, string softCode, string softVersion, string dealerCode, int announcementType);

参数说明

参数名类型说明
userCode字符串用户码。
softCode字符串软件码。
softVersion字符串软件版本。
dealerCode字符串经销商码。
announcementType整数公告类型。

示例

SDK 调用

cpp
#include "OLAPlugServer.h"

OLAPlugServer ola;
int ret = ola.GetAnnouncementsByType("value", "value", "value", "value", 0);
csharp
using OLAPlug;

var ola = new OLAPlugServer();
int ret = ola.GetAnnouncementsByType("value", "value", "value", "value", 0);
python
from OLAPlugServer import OLAPlugServer

ola = OLAPlugServer()
ret = ola.GetAnnouncementsByType("value", "value", "value", "value", 0)
java
import com.olaplug.OLAPlugServer;

OLAPlugServer ola = new OLAPlugServer();
int ret = ola.GetAnnouncementsByType("value", "value", "value", "value", 0);
cpp
var ola = com("OlaPlug.OlaSoft")
var ret = ola.GetAnnouncementsByType("value", "value", "value", "value", 0)
vbscript
Set ola = CreateObject("OlaPlug.OlaSoft")
ret = ola.GetAnnouncementsByType("value", "value", "value", "value", 0)
text
.局部变量 ola, OLAPlug
ola.创建 ()
ret = ola.GetAnnouncementsByType(“value”, “value”, “value”, “value”, 0)
aardio
import OLAPlugServer;
var ola = OLAPlugServer();
var ret = ola.GetAnnouncementsByType("value", "value", "value", "value", 0);
text
变量 ola <类型 = OLAPlugServer>
ola = 新建 OLAPlugServer
整数 ret = ola.GetAnnouncementsByType("value", "value", "value", "value", 0)
cpp
#include "OLAPlugServer.h"

OLAPlugServer ola;
int32_t ret = ola.GetAnnouncementsByType("value", "value", "value", "value", 0);

原生 DLL 调用

cpp
long ptr = GetAnnouncementsByType(instance, "value", "value", "value", "value", 0);
if (ptr != 0) {
    char buffer[512] = {0};
    GetStringFromPtr(ptr, buffer, sizeof(buffer));
    FreeStringPtr(ptr);
}
csharp
using System.Runtime.InteropServices;
using System.Text;

[DllImport("OLAPlug_x64.dll", CallingConvention = CallingConvention.StdCall)]
static extern int GetStringFromPtr(long ptr, StringBuilder lpString, int size);
[DllImport("OLAPlug_x64.dll", CallingConvention = CallingConvention.StdCall)]
static extern int FreeStringPtr(long ptr);
[DllImport("OLAPlug_x64.dll", CallingConvention = CallingConvention.StdCall)]
static extern int GetStringSize(long ptr);
[DllImport("OLAPlug_x64.dll", CallingConvention = CallingConvention.StdCall)]
static extern long GetAnnouncementsByType(string userCode, string softCode, string softVersion, string dealerCode, int announcementType);

long ptr = GetAnnouncementsByType(instance, "value", "value", "value", "value", 0);
if (ptr != 0) {
    StringBuilder sb = new StringBuilder(GetStringSize(ptr) + 1);
    GetStringFromPtr(ptr, sb, sb.Capacity);
    FreeStringPtr(ptr);
    string result = sb.ToString();
}
python
from ctypes import CDLL, c_int, c_int64, create_string_buffer

ola = CDLL("OLAPlug_x64.dll")
ola.CreateCOLAPlugInterFace.restype = c_int64
ptr = ola.GetAnnouncementsByType(instance, "value", "value", "value", "value", 0)
if ptr:
    buf = create_string_buffer(512)
    ola.GetStringFromPtr(ptr, buf, 512)
    ola.FreeStringPtr(ptr)
    result = buf.value.decode("utf-8")

返回值

成功返回 JSON 字符串格式的公告结果;失败返回 0。

注意事项

  • 返回的字符串指针需要调用 FreeStringPtr 接口释放内存。
  • 公告类型值请与服务端定义保持一致。